<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="员工姓名" prop="employeeName">
        <el-input
          v-model="queryParams.employeeName"
          placeholder="请输入员工姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工号" prop="jobNumber">
        <el-input
          v-model="queryParams.jobNumber"
          placeholder="请输入工号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="primary"-->
<!--          plain-->
<!--          icon="el-icon-plus"-->
<!--          size="mini"-->
<!--          @click="handleAdd"-->
<!--          v-hasPermi="['hr:attendDetail:add']"-->
<!--        >同步考勤数据(钉钉)-->
<!--        </el-button>-->
<!--      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd2"
          v-hasPermi="['hr:attendDetail:add']"
        >同步考勤数据
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['hr:attendDetail:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['hr:attendDetail:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['hr:attendDetail:export']"
        >导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
        >导入
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="attendDetailList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="公司代码" align="center" prop="gcCode"/>
      <el-table-column label="公司名称" align="center" prop="gcName"/>
      <el-table-column label="考勤年月" align="center" prop="nyDate"/>
      <el-table-column label="员工姓名" align="center" prop="employeeName"/>
      <el-table-column label="工号" align="center" prop="jobNumber" width="160"/>
      <el-table-column label="部门" align="center" prop="department"/>
      <el-table-column label="分部" align="center" prop="branch"/>
      <el-table-column label="组别" align="center" prop="zb"/>
      <el-table-column label="岗位" align="center" prop="jobs"/>
      <el-table-column label="1日" align="center" prop="day1" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day1=='缺勤'" style="color: red">{{ scope.row.day1 }}</span>
          <span v-else-if="scope.row.day1==='全天正常'" style="color: #13ce66">{{ scope.row.day1 }}</span>
          <span v-else-if="scope.row.day1==='周末休班'" style="color: #00afff">{{ scope.row.day1 }}</span>
          <span v-else-if="scope.row.day1==='周末加班'" style="color: mediumturquoise">{{ scope.row.day1 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="2日" align="center" prop="day2" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day2=='缺勤'" style="color: red">{{ scope.row.day2 }}</span>
          <span v-else-if="scope.row.day2=='全天正常'" style="color: #13ce66">{{ scope.row.day2 }}</span>
          <span v-else-if="scope.row.day2=='周末休班'" style="color: #00afff">{{ scope.row.day2 }}</span>
          <span v-else-if="scope.row.day2=='周末加班'" style="color: mediumturquoise">{{ scope.row.day2 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day2}}</span>
        </template>
      </el-table-column>
      <el-table-column label="3日" align="center" prop="day3" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day3=='缺勤'" style="color: red">{{ scope.row.day3 }}</span>
          <span v-else-if="scope.row.day3=='全天正常'" style="color: #13ce66">{{ scope.row.day3 }}</span>
          <span v-else-if="scope.row.day3=='周末休班'" style="color: #00afff">{{ scope.row.day3 }}</span>
          <span v-else-if="scope.row.day3=='周末加班'" style="color: mediumturquoise">{{ scope.row.day3 }}</span>
          <span v-else style="color: #2b2f3a" >{{ scope.row.day3}}</span>
        </template>
      </el-table-column>
      <el-table-column label="4日" align="center" prop="day4" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day4=='缺勤'" style="color: red">{{ scope.row.day4 }}</span>
          <span v-else-if="scope.row.day4=='全天正常'" style="color: #13ce66">{{ scope.row.day4 }}</span>
          <span v-else-if="scope.row.day4=='周末休班'" style="color: #00afff">{{ scope.row.day4 }}</span>
          <span v-else-if="scope.row.day4=='周末加班'" style="color: mediumturquoise">{{ scope.row.day4 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day4}}</span>
        </template>
      </el-table-column>
      <el-table-column label="5日" align="center" prop="day5" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day5=='缺勤'" style="color: red">{{ scope.row.day5 }}</span>
          <span v-else-if="scope.row.day5==='全天正常'" style="color: #13ce66">{{ scope.row.day5 }}</span>
          <span v-else-if="scope.row.day5==='周末休班'" style="color: #00afff">{{ scope.row.day5 }}</span>
          <span v-else-if="scope.row.day5==='周末加班'" style="color: mediumturquoise">{{ scope.row.day5 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day5}}</span>
        </template>
      </el-table-column>
      <el-table-column label="6日" align="center" prop="day6" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day6=='缺勤'" style="color: red">{{ scope.row.day6 }}</span>
          <span v-else-if="scope.row.day6=='全天正常'" style="color: #13ce66">{{ scope.row.day6 }}</span>
          <span v-else-if="scope.row.day6=='周末休班'" style="color: #00afff">{{ scope.row.day6 }}</span>
          <span v-else-if="scope.row.day6=='周末加班'" style="color: mediumturquoise">{{ scope.row.day6 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day6}}</span>
        </template>
      </el-table-column>
      <el-table-column label="7日" align="center" prop="day7" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day7=='缺勤'" style="color: red">{{ scope.row.day7 }}</span>
          <span v-else-if="scope.row.day7=='全天正常'" style="color: #13ce66">{{ scope.row.day7 }}</span>
          <span v-else-if="scope.row.day7=='周末休班'" style="color: #00afff">{{ scope.row.day7 }}</span>
          <span v-else-if="scope.row.day7=='周末加班'" style="color: mediumturquoise">{{ scope.row.day7 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day7}}</span>
        </template>
      </el-table-column>
      <el-table-column label="8日" align="center" prop="day8" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day8=='缺勤'" style="color: red">{{ scope.row.day8 }}</span>
          <span v-else-if="scope.row.day8=='全天正常'" style="color: #13ce66">{{ scope.row.day8 }}</span>
          <span v-else-if="scope.row.day8=='周末休班'" style="color: #00afff">{{ scope.row.day8 }}</span>
          <span v-else-if="scope.row.day8=='周末加班'" style="color: mediumturquoise">{{ scope.row.day8 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day8}}</span>
        </template>
      </el-table-column>
      <el-table-column label="9日" align="center" prop="day9" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day9=='缺勤'" style="color: red">{{ scope.row.day9 }}</span>
          <span v-else-if="scope.row.day9=='全天正常'" style="color: #13ce66">{{ scope.row.day9 }}</span>
          <span v-else-if="scope.row.day9=='周末休班'" style="color: #00afff">{{ scope.row.day9 }}</span>
          <span v-else-if="scope.row.day9=='周末加班'" style="color: mediumturquoise">{{ scope.row.day9 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day9}}</span>
        </template>
      </el-table-column>
      <el-table-column label="10日" align="center" prop="day10" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day10=='缺勤'" style="color: red">{{ scope.row.day10 }}</span>
          <span v-else-if="scope.row.day10=='全天正常'" style="color: #13ce66">{{ scope.row.day10 }}</span>
          <span v-else-if="scope.row.day10=='周末休班'" style="color: #00afff">{{ scope.row.day10 }}</span>
          <span v-else-if="scope.row.day10=='周末加班'" style="color: mediumturquoise">{{ scope.row.day10 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day10}}</span>
        </template>
      </el-table-column>
      <el-table-column label="11日" align="center" prop="day11" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day11=='缺勤'" style="color: red">{{ scope.row.day11 }}</span>
          <span v-else-if="scope.row.day11=='全天正常'" style="color: #13ce66">{{ scope.row.day11 }}</span>
          <span v-else-if="scope.row.day11=='周末休班'" style="color: #00afff">{{ scope.row.day11 }}</span>
          <span v-else-if="scope.row.day11=='周末加班'" style="color: mediumturquoise">{{ scope.row.day11 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day11}}</span>
        </template>
      </el-table-column>
      <el-table-column label="12日" align="center" prop="day12" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day12=='缺勤'" style="color: red">{{ scope.row.day12 }}</span>
          <span v-else-if="scope.row.day12=='全天正常'" style="color: #13ce66">{{ scope.row.day12 }}</span>
          <span v-else-if="scope.row.day12=='周末休班'" style="color: #00afff">{{ scope.row.day12 }}</span>
          <span v-else-if="scope.row.day12=='周末加班'" style="color: mediumturquoise">{{ scope.row.day12 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day12}}</span>
        </template>
      </el-table-column>
      <el-table-column label="13日" align="center" prop="day13" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day13=='缺勤'" style="color: red">{{ scope.row.day13 }}</span>
          <span v-else-if="scope.row.day13=='全天正常'" style="color: #13ce66">{{ scope.row.day13 }}</span>
          <span v-else-if="scope.row.day13=='周末休班'" style="color: #00afff">{{ scope.row.day13 }}</span>
          <span v-else-if="scope.row.day13=='周末加班'" style="color: mediumturquoise">{{ scope.row.day13 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day13}}</span>
        </template>
      </el-table-column>
      <el-table-column label="14日" align="center" prop="day14" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day14=='缺勤'" style="color: red">{{ scope.row.day14 }}</span>
          <span v-else-if="scope.row.day14=='全天正常'" style="color: #13ce66">{{ scope.row.day14 }}</span>
          <span v-else-if="scope.row.day14=='周末休班'" style="color: #00afff">{{ scope.row.day14 }}</span>
          <span v-else-if="scope.row.day14=='周末加班'" style="color: mediumturquoise">{{ scope.row.day14 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day14}}</span>
        </template>
      </el-table-column>
      <el-table-column label="15日" align="center" prop="day15" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day15=='缺勤'" style="color: red">{{ scope.row.day15 }}</span>
          <span v-else-if="scope.row.day15=='全天正常'" style="color: #13ce66">{{ scope.row.day15 }}</span>
          <span v-else-if="scope.row.day15=='周末休班'" style="color: #00afff">{{ scope.row.day15 }}</span>
          <span v-else-if="scope.row.day15=='周末加班'" style="color: mediumturquoise">{{ scope.row.day15 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day15}}</span>
        </template>
      </el-table-column>
      <el-table-column label="16日" align="center" prop="day16" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day16=='缺勤'" style="color: red">{{ scope.row.day16 }}</span>
          <span v-else-if="scope.row.day16=='全天正常'" style="color: #13ce66">{{ scope.row.day16 }}</span>
          <span v-else-if="scope.row.day16=='周末休班'" style="color: #00afff">{{ scope.row.day16 }}</span>
          <span v-else-if="scope.row.day16=='周末加班'" style="color: mediumturquoise">{{ scope.row.day16 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day16}}</span>
        </template>
      </el-table-column>
      <el-table-column label="17日" align="center" prop="day17" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day17=='缺勤'" style="color: red">{{ scope.row.day17 }}</span>
          <span v-else-if="scope.row.day17=='全天正常'" style="color: #13ce66">{{ scope.row.day17 }}</span>
          <span v-else-if="scope.row.day17=='周末休班'" style="color: #00afff">{{ scope.row.day17 }}</span>
          <span v-else-if="scope.row.day17=='周末加班'" style="color: mediumturquoise">{{ scope.row.day17 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day17}}</span>
        </template>
      </el-table-column>
      <el-table-column label="18日" align="center" prop="day18" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day18=='缺勤'" style="color: red">{{ scope.row.day18 }}</span>
          <span v-else-if="scope.row.day18=='全天正常'" style="color: #13ce66">{{ scope.row.day18 }}</span>
          <span v-else-if="scope.row.day18=='周末休班'" style="color: #00afff">{{ scope.row.day18 }}</span>
          <span v-else-if="scope.row.day18=='周末加班'" style="color: mediumturquoise">{{ scope.row.day18 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day18}}</span>
        </template>
      </el-table-column>
      <el-table-column label="19日" align="center" prop="day19" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day19=='缺勤'" style="color: red">{{ scope.row.day19 }}</span>
          <span v-else-if="scope.row.day19=='全天正常'" style="color: #13ce66">{{ scope.row.day19 }}</span>
          <span v-else-if="scope.row.day19=='周末休班'" style="color: #00afff">{{ scope.row.day19 }}</span>
          <span v-else-if="scope.row.day19=='周末加班'" style="color: mediumturquoise">{{ scope.row.day19 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day19}}</span>
        </template>
      </el-table-column>
      <el-table-column label="20日" align="center" prop="day20" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day20=='缺勤'" style="color: red">{{ scope.row.day20 }}</span>
          <span v-else-if="scope.row.day20=='全天正常'" style="color: #13ce66">{{ scope.row.day20 }}</span>
          <span v-else-if="scope.row.day20=='周末休班'" style="color: #00afff">{{ scope.row.day20 }}</span>
          <span v-else-if="scope.row.day20=='周末加班'" style="color: mediumturquoise">{{ scope.row.day20 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day20}}</span>
        </template>
      </el-table-column>
      <el-table-column label="21日" align="center" prop="day21" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day21=='缺勤'" style="color: red">{{ scope.row.day21 }}</span>
          <span v-else-if="scope.row.day21=='全天正常'" style="color: #13ce66">{{ scope.row.day21 }}</span>
          <span v-else-if="scope.row.day21=='周末休班'" style="color: #00afff">{{ scope.row.day21 }}</span>
          <span v-else-if="scope.row.day21=='周末加班'" style="color: mediumturquoise">{{ scope.row.day21 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day21}}</span>
        </template>
      </el-table-column>
      <el-table-column label="22日" align="center" prop="day22" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day22=='缺勤'" style="color: red">{{ scope.row.day22 }}</span>
          <span v-else-if="scope.row.day22=='全天正常'" style="color: #13ce66">{{ scope.row.day22 }}</span>
          <span v-else-if="scope.row.day22=='周末休班'" style="color: #00afff">{{ scope.row.day22 }}</span>
          <span v-else-if="scope.row.day22=='周末加班'" style="color: mediumturquoise">{{ scope.row.day22 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day22}}</span>
        </template>
      </el-table-column>
      <el-table-column label="23日" align="center" prop="day23" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day23=='缺勤'" style="color: red">{{ scope.row.day23 }}</span>
          <span v-else-if="scope.row.day23=='全天正常'" style="color: #13ce66">{{ scope.row.day23 }}</span>
          <span v-else-if="scope.row.day23=='周末休班'" style="color: #00afff">{{ scope.row.day23 }}</span>
          <span v-else-if="scope.row.day23=='周末加班'" style="color: mediumturquoise">{{ scope.row.day23 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day23}}</span>
        </template>
      </el-table-column>
      <el-table-column label="24日" align="center" prop="day24" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day24=='缺勤'" style="color: red">{{ scope.row.day24 }}</span>
          <span v-else-if="scope.row.day24=='全天正常'" style="color: #13ce66">{{ scope.row.day24 }}</span>
          <span v-else-if="scope.row.day24=='周末休班'" style="color: #00afff">{{ scope.row.day24 }}</span>
          <span v-else-if="scope.row.day24=='周末加班'" style="color: mediumturquoise">{{ scope.row.day24 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day24}}</span>
        </template>
      </el-table-column>
      <el-table-column label="25日" align="center" prop="day25" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day25=='缺勤'" style="color: red">{{ scope.row.day25 }}</span>
          <span v-else-if="scope.row.day25=='全天正常'" style="color: #13ce66">{{ scope.row.day25 }}</span>
          <span v-else-if="scope.row.day25=='周末休班'" style="color: #00afff">{{ scope.row.day25 }}</span>
          <span v-else-if="scope.row.day25=='周末加班'" style="color: mediumturquoise">{{ scope.row.day25 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day25}}</span>
        </template>
      </el-table-column>
      <el-table-column label="26日" align="center" prop="day26" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day26=='缺勤'" style="color: red">{{ scope.row.day26 }}</span>
          <span v-else-if="scope.row.day26=='全天正常'" style="color: #13ce66">{{ scope.row.day26 }}</span>
          <span v-else-if="scope.row.day26=='周末休班'" style="color: #00afff">{{ scope.row.day26 }}</span>
          <span v-else-if="scope.row.day26=='周末加班'" style="color: mediumturquoise">{{ scope.row.day26 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day26}}</span>
        </template>
      </el-table-column>
      <el-table-column label="27日" align="center" prop="day27" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day27=='缺勤'" style="color: red">{{ scope.row.day27 }}</span>
          <span v-else-if="scope.row.day27=='全天正常'" style="color: #13ce66">{{ scope.row.day27 }}</span>
          <span v-else-if="scope.row.day27=='周末休班'" style="color: #00afff">{{ scope.row.day27 }}</span>
          <span v-else-if="scope.row.day27=='周末加班'" style="color: mediumturquoise">{{ scope.row.day27 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day27}}</span>
        </template>
      </el-table-column>
      <el-table-column label="28日" align="center" prop="day28" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day28=='缺勤'" style="color: red">{{ scope.row.day28 }}</span>
          <span v-else-if="scope.row.day28=='全天正常'" style="color: #13ce66">{{ scope.row.day28 }}</span>
          <span v-else-if="scope.row.day28=='周末休班'" style="color: #00afff">{{ scope.row.day28 }}</span>
          <span v-else-if="scope.row.day28=='周末加班'" style="color: mediumturquoise">{{ scope.row.day28 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day28}}</span>
        </template>
      </el-table-column>
      <el-table-column label="29日" align="center" prop="day29" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day29=='缺勤'" style="color: red">{{ scope.row.day29 }}</span>
          <span v-else-if="scope.row.day29=='全天正常'" style="color: #13ce66">{{ scope.row.day29 }}</span>
          <span v-else-if="scope.row.day29=='周末休班'" style="color: #00afff">{{ scope.row.day29 }}</span>
          <span v-else-if="scope.row.day29=='周末加班'" style="color: mediumturquoise">{{ scope.row.day29 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day29}}</span>
        </template>
      </el-table-column>
      <el-table-column label="30日" align="center" prop="day30" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day30=='缺勤'" style="color: red">{{ scope.row.day30 }}</span>
          <span v-else-if="scope.row.day30=='全天正常'" style="color: #13ce66">{{ scope.row.day30 }}</span>
          <span v-else-if="scope.row.day30=='周末休班'" style="color: #00afff">{{ scope.row.day30 }}</span>
          <span v-else-if="scope.row.day30=='周末加班'" style="color: mediumturquoise">{{ scope.row.day30 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day30}}</span>
        </template>
      </el-table-column>
      <el-table-column label="31日" align="center" prop="day31" width="160" show-tooltip-when-overflow>
        <template slot-scope="scope">
          <span v-if="scope.row.day31=='缺勤'" style="color: red">{{ scope.row.day31 }}</span>
          <span v-else-if="scope.row.day31=='全天正常'" style="color: #13ce66">{{ scope.row.day31 }}</span>
          <span v-else-if="scope.row.day31=='周末休班'" style="color: #00afff">{{ scope.row.day31 }}</span>
          <span v-else-if="scope.row.day31=='周末加班'" style="color: mediumturquoise">{{ scope.row.day31 }}</span>
          <span v-else style="color: #2b2f3a">{{ scope.row.day31}}</span>
        </template>
      </el-table-column>
      <el-table-column label="正常加班时间(分钟)" align="center" prop="jbMin" width="140">
        <template slot-scope="scope">
          <span>{{ scope.row.jbMin }}</span>
        </template>
      </el-table-column>
      <el-table-column label="周末加班时间(天)" align="center" prop="jbWeekend" width="140">
        <template slot-scope="scope">
          <span>{{ scope.row.jbWeekend| numFilter }}</span>
        </template>
      </el-table-column>
      <el-table-column label="节假日加班时间(天)" align="center" prop="jbJjr" width="160">
        <template slot-scope="scope">
          <span>{{ scope.row.jbJjr| numFilter }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="120">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['hr:attendDetail:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['hr:attendDetail:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改考勤明细对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="公司代码" prop="gcCode">
          <el-input v-model="form.gcCode" placeholder="请输入公司代码"/>
        </el-form-item>
        <el-form-item label="公司名称" prop="gcName">
          <el-input v-model="form.gcName" placeholder="请输入公司名称"/>
        </el-form-item>
        <el-form-item label="员工姓名" prop="employeeName">
          <el-input v-model="form.employeeName" placeholder="请输入员工姓名"/>
        </el-form-item>
        <el-form-item label="工号" prop="jobNumber">
          <el-input v-model="form.jobNumber" placeholder="请输入工号"/>
        </el-form-item>
        <el-form-item label="分部" prop="branch">
          <el-input v-model="form.branch" placeholder="请输入分部"/>
        </el-form-item>
        <el-form-item label="组别" prop="zb">
          <el-input v-model="form.zb" placeholder="请输入组别"/>
        </el-form-item>
        <el-form-item label="岗位" prop="jobs">
          <el-input v-model="form.jobs" placeholder="请输入岗位"/>
        </el-form-item>
        <el-form-item label="1日" prop="day1">
          <el-input v-model="form.day1" placeholder="请输入1日"/>
        </el-form-item>
        <el-form-item label="2日" prop="day2">
          <el-input v-model="form.day2" placeholder="请输入2日"/>
        </el-form-item>
        <el-form-item label="3日" prop="day3">
          <el-input v-model="form.day3" placeholder="请输入3日"/>
        </el-form-item>
        <el-form-item label="4日" prop="day4">
          <el-input v-model="form.day4" placeholder="请输入4日"/>
        </el-form-item>
        <el-form-item label="5日" prop="day5">
          <el-input v-model="form.day5" placeholder="请输入5日"/>
        </el-form-item>
        <el-form-item label="6日" prop="day6">
          <el-input v-model="form.day6" placeholder="请输入6日"/>
        </el-form-item>
        <el-form-item label="7日" prop="day7">
          <el-input v-model="form.day7" placeholder="请输入7日"/>
        </el-form-item>
        <el-form-item label="8日" prop="day8">
          <el-input v-model="form.day8" placeholder="请输入8日"/>
        </el-form-item>
        <el-form-item label="9日" prop="day9">
          <el-input v-model="form.day9" placeholder="请输入9日"/>
        </el-form-item>
        <el-form-item label="10日" prop="day10">
          <el-input v-model="form.day10" placeholder="请输入10日"/>
        </el-form-item>
        <el-form-item label="11日" prop="day11">
          <el-input v-model="form.day11" placeholder="请输入11日"/>
        </el-form-item>
        <el-form-item label="12日" prop="day12">
          <el-input v-model="form.day12" placeholder="请输入12日"/>
        </el-form-item>
        <el-form-item label="13日" prop="day13">
          <el-input v-model="form.day13" placeholder="请输入13日"/>
        </el-form-item>
        <el-form-item label="14日" prop="day14">
          <el-input v-model="form.day14" placeholder="请输入14日"/>
        </el-form-item>
        <el-form-item label="15日" prop="day15">
          <el-input v-model="form.day15" placeholder="请输入15日"/>
        </el-form-item>
        <el-form-item label="16日" prop="day16">
          <el-input v-model="form.day16" placeholder="请输入16日"/>
        </el-form-item>
        <el-form-item label="17日" prop="day17">
          <el-input v-model="form.day17" placeholder="请输入17日"/>
        </el-form-item>
        <el-form-item label="18日" prop="day18">
          <el-input v-model="form.day18" placeholder="请输入18日"/>
        </el-form-item>
        <el-form-item label="19日" prop="day19">
          <el-input v-model="form.day19" placeholder="请输入19日"/>
        </el-form-item>
        <el-form-item label="20日" prop="day20">
          <el-input v-model="form.day20" placeholder="请输入20日"/>
        </el-form-item>
        <el-form-item label="21日" prop="day21">
          <el-input v-model="form.day21" placeholder="请输入21日"/>
        </el-form-item>
        <el-form-item label="22日" prop="day22">
          <el-input v-model="form.day22" placeholder="请输入22日"/>
        </el-form-item>
        <el-form-item label="23日" prop="day23">
          <el-input v-model="form.day23" placeholder="请输入23日"/>
        </el-form-item>
        <el-form-item label="24日" prop="day24">
          <el-input v-model="form.day24" placeholder="请输入24日"/>
        </el-form-item>
        <el-form-item label="25日" prop="day25">
          <el-input v-model="form.day25" placeholder="请输入25日"/>
        </el-form-item>
        <el-form-item label="26日" prop="day26">
          <el-input v-model="form.day26" placeholder="请输入26日"/>
        </el-form-item>
        <el-form-item label="27日" prop="day27">
          <el-input v-model="form.day27" placeholder="请输入27日"/>
        </el-form-item>
        <el-form-item label="28日" prop="day28">
          <el-input v-model="form.day28" placeholder="请输入28日"/>
        </el-form-item>
        <el-form-item label="29日" prop="day29">
          <el-input v-model="form.day29" placeholder="请输入29日"/>
        </el-form-item>
        <el-form-item label="30日" prop="day30">
          <el-input v-model="form.day30" placeholder="请输入30日"/>
        </el-form-item>
        <el-form-item label="31日" prop="day31">
          <el-input v-model="form.day31" placeholder="请输入31日"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" width="400px"
               append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
                   @click="importTemplate">下载模板
          </el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listAttendDetail,
  getAttendDetail,
  delAttendDetail,
  addAttendDetail,
  updateAttendDetail,
  getAttendTjDetail
} from "@/api/hr/attendDetail";
import {getToken} from "@/utils/auth";

export default {
  name: "AttendDetail",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 考勤明细表格数据
      attendDetailList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        gcCode: null,
        gcName: null,
        employeeName: null,
        jobNumber: null,
        department: null,
        branch: null,
        zb: null,
        jobs: null,
        day1: null,
        day2: null,
        day3: null,
        day4: null,
        day5: null,
        day6: null,
        day7: null,
        day8: null,
        day9: null,
        day10: null,
        day11: null,
        day12: null,
        day13: null,
        day14: null,
        day15: null,
        day16: null,
        day17: null,
        day18: null,
        day19: null,
        day20: null,
        day21: null,
        day22: null,
        day23: null,
        day24: null,
        day25: null,
        day26: null,
        day27: null,
        day28: null,
        day29: null,
        day30: null,
        day31: null,
      },
      // 表单参数
      form: {},
      //考勤导入
      upload: {
        // 是否显示弹出层（物料导入）
        open: false,
        // 弹出层标题（物料导入）
        title: "导入考勤明细",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/hr/attendDetail/importData"
      },
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  filters: {
    numFilter (value) {
      // 截取当前数据到小数点后两位
      let realVal = parseFloat(value).toFixed(1)
      return realVal
    }
  },
  methods: {
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "原始考勤导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('hr/attendDetail/importTemplate', {}, `考勤明细.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", {dangerouslyUseHTMLString: true});
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    /** 查询考勤明细列表 */
    getList() {
      this.loading = true;
      listAttendDetail(this.queryParams).then(response => {
        this.attendDetailList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        gcCode: null,
        gcName: null,
        employeeName: null,
        jobNumber: null,
        department: null,
        branch: null,
        zb: null,
        jobs: null,
        day1: null,
        day2: null,
        day3: null,
        day4: null,
        day5: null,
        day6: null,
        day7: null,
        day8: null,
        day9: null,
        day10: null,
        day11: null,
        day12: null,
        day13: null,
        day14: null,
        day15: null,
        day16: null,
        day17: null,
        day18: null,
        day19: null,
        day20: null,
        day21: null,
        day22: null,
        day23: null,
        day24: null,
        day25: null,
        day26: null,
        day27: null,
        day28: null,
        day29: null,
        day30: null,
        day31: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      getAttendTjDetail("new").then(response => {
        if (response.code == 200) {
          this.getList();
          this.$modal.msgSuccess("同步成功");
        }
        loading.close();
      }).catch(() => {
        loading.close();
      });
    },
    handleAdd2() {
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      getAttendTjDetail("old").then(response => {
        if (response.code == 200) {
          this.getList();
          this.$modal.msgSuccess("同步成功");
        }
        loading.close();
      }).catch(() => {
        loading.close();
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getAttendDetail(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改考勤明细";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateAttendDetail(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addAttendDetail(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除考勤明细编号为"' + ids + '"的数据项？').then(function () {
        return delAttendDetail(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('hr/attendDetail/export', {
        ...this.queryParams
      }, `attendDetail_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
